import Vue from 'vue';
import Vuex from 'vuex';
Vue.use(Vuex);

//状态
let state = {
    isShowHead : true, //头部导航栏
    userName:'',
    loadPermission: ""
};
let getters = {
    showHead(){ //头部导航栏
        return state.isShowHead
    },
    setUserName(){
        return state.userName
    }
};
const actions = {
    //头部导航栏 start
    showHead({commit}) {
        commit('SHOWHEAD')
    },
    hiddenHead({commit}){
        commit('HIDDENHEAD')
    },
    //头部导航栏 end
    setUserName(context,item){
        context.commit('EDITNAME',item)
    },
    loadPermission({commit}) {
        commit('LOAD_PERMISSION',true)
    },
    clearloadPermission({commit}) {
        commit('LOAD_PERMISSION',false)
    }
};
const mutations = {
    //头部导航栏 start
    SHOWHEAD(state){
        state.isShowHead = true
    },
    HIDDENHEAD(state){
        state.isShowHead = false
    },
    //头部导航栏 end
    EDITNAME(state,item){
      state.userName = item
    },

    LOAD_PERMISSION(state,item) {
        state.loadPermission = item;
    },
};
const store = new Vuex.Store({
    state,
    actions,
    mutations,
    getters
});

export default store;
